home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / NumberFormatting.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  3.7 KB  |  154 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        NumberFormatting.p
  3.  
  4.      Contains:    Utilites for formatting numbers
  5.  
  6.      Version:    Technology:    
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1996-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT NumberFormatting;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __NUMBERFORMATTING__}
  28. {$SETC __NUMBERFORMATTING__ := 1}
  29.  
  30. {$I+}
  31. {$SETC NumberFormattingIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __CONDITIONALMACROS__}
  35. {$I ConditionalMacros.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __INTLRESOURCES__}
  41. {$I IntlResources.p}
  42. {$ENDC}
  43.  
  44.  
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. {
  51.  
  52.     Here are the current System 7 routine names and the translations to the older forms.
  53.     Please use the newer forms in all new code and migrate the older names out of existing
  54.     code as maintainance permits.
  55.     
  56.     New Name                    Old Name(s)
  57.     
  58.     ExtendedToString            FormatX2Str
  59.     FormatRecToString            Format2Str
  60.     NumToString                
  61.     StringToExtended            FormatStr2X
  62.     StringToFormatRec            Str2Format
  63.     StringToNum                
  64.  
  65. }
  66.  
  67. TYPE
  68.     NumFormatStringPtr = ^NumFormatString;
  69.     NumFormatString = PACKED RECORD
  70.         fLength:                UInt8;
  71.         fVersion:                UInt8;
  72.         data:                    PACKED ARRAY [0..253] OF CHAR;            {  private data  }
  73.     END;
  74.  
  75.     NumFormatStringRec                    = NumFormatString;
  76.     NumFormatStringRecPtr                 = ^NumFormatStringRec;
  77.     FormatStatus                        = INTEGER;
  78.  
  79. CONST
  80.     fVNumber                    = 0;                            {  first version of NumFormatString  }
  81.  
  82.  
  83. TYPE
  84.     FormatClass                            = SInt8;
  85.  
  86. CONST
  87.     fPositive                    = 0;
  88.     fNegative                    = 1;
  89.     fZero                        = 2;
  90.  
  91.  
  92. TYPE
  93.     FormatResultType                    = SInt8;
  94.  
  95. CONST
  96.     fFormatOK                    = 0;
  97.     fBestGuess                    = 1;
  98.     fOutOfSynch                    = 2;
  99.     fSpuriousChars                = 3;
  100.     fMissingDelimiter            = 4;
  101.     fExtraDecimal                = 5;
  102.     fMissingLiteral                = 6;
  103.     fExtraExp                    = 7;
  104.     fFormatOverflow                = 8;
  105.     fFormStrIsNAN                = 9;
  106.     fBadPartsTable                = 10;
  107.     fExtraPercent                = 11;
  108.     fExtraSeparator                = 12;
  109.     fEmptyFormatString            = 13;
  110.  
  111.  
  112. TYPE
  113.     FVectorPtr = ^FVector;
  114.     FVector = RECORD
  115.         start:                    INTEGER;
  116.         length:                    INTEGER;
  117.     END;
  118.  
  119. { index by [fPositive..fZero] }
  120.     TripleInt                            = ARRAY [0..2] OF FVector;
  121. PROCEDURE StringToNum(theString: ConstStr255Param; VAR theNum: LONGINT);
  122. PROCEDURE NumToString(theNum: LONGINT; VAR theString: Str255);
  123.  
  124. FUNCTION ExtendedToString({CONST}VAR x: extended80; {CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR outString: Str255): FormatStatus;
  125.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  126.     INLINE $2F3C, $8210, $FFE8, $A8B5;
  127.     {$ENDC}
  128. FUNCTION StringToExtended(source: ConstStr255Param; {CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR x: extended80): FormatStatus;
  129.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  130.     INLINE $2F3C, $8210, $FFE6, $A8B5;
  131.     {$ENDC}
  132. FUNCTION StringToFormatRec(inString: ConstStr255Param; {CONST}VAR partsTable: NumberParts; VAR outString: NumFormatString): FormatStatus;
  133.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  134.     INLINE $2F3C, $820C, $FFEC, $A8B5;
  135.     {$ENDC}
  136. FUNCTION FormatRecToString({CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR outString: Str255; VAR positions: TripleInt): FormatStatus;
  137.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  138.     INLINE $2F3C, $8210, $FFEA, $A8B5;
  139.     {$ENDC}
  140.  
  141. {$IFC OLDROUTINENAMES }
  142. {$ENDC}  {OLDROUTINENAMES}
  143.  
  144. {$ALIGN RESET}
  145. {$POP}
  146.  
  147. {$SETC UsingIncludes := NumberFormattingIncludes}
  148.  
  149. {$ENDC} {__NUMBERFORMATTING__}
  150.  
  151. {$IFC NOT UsingIncludes}
  152.  END.
  153. {$ENDC}
  154.